<?php

include "koneksi.php";
include "function.php";

$atas = 'D';
$bawah = 'B';

$perbandingan =  getPerbandingan($atas,$bawah);
echo "perbandingan : $atas / $bawah : $perbandingan";

echo "<br/><br/><br/>";
$nilaikepribadian = "1,2";
$kepribadian[]="";
$kepribadian = getKepribadian($nilaikepribadian);
$i = 0;
while($kepribadian){
    
    if($kepribadian[$i] == ""){
        break;
    }
    echo "data : $kepribadian[$i]";
    $i++;
}

echo "<br/><br/><br/>";

$lowongan = 1;
$low = getLowongan($lowongan);
echo "Data Pelamar $low<br/>
<table><tr><td>No</td><td>Nama</td><td>Logika</td><td>Kecermatan</td><td>Kepribadian</td><td>Karakter</td></tr>";
$no = 1;
$pelamar = getPelamar($lowongan);
$pelamarid[][]="";
$a=0;
while($data = mysql_fetch_array($pelamar)){
    $pelamarid[$a][0]=getLogika($data[logika]);
    $pelamarid[$a][1]=getKecermatan($data[kecermatan]);
    $pelamarid[$a][2]=$data[kepribadian];
    $pelamarid[$a][3]=$data[karakter];
//    echo "<tr><td>$no</td><td>".getNamaPelamar($data[id_pelamar])."</td><td>".getLogika($data[logika])."</td><td>".getKecermatan($data[kecermatan])."</td><td>$data[kepribadian]</td><td>$data[karakter]</td></tr>";
    echo "<tr><td>$no</td><td>".getNamaPelamar($data[id_pelamar])."</td><td>".$pelamarid[$a][0]."</td><td>".$pelamarid[$a][1]."</td><td>".$pelamarid[$a][2]."</td><td>".$pelamarid[$a][0]."</td></tr>";
    $a++;
    $no++;
}
echo "</table>";

echo "<br/><br/><br/>";

echo "Logika<br/>";
$log = 0;
echo "<table border=1>";
for($log=0;$log<$a;$log++){
    echo "<tr>";
    for($log1=0;$log1<$a;$log1++){
        echo "<td>".getPerbandingan($pelamarid[$log][0],$pelamarid[$log1][0])."</td>";
    }
    echo "</tr>";
}
$logic[]="";
echo "<tr>";
for($log=0;$log<$a;$log++){
    for($log1=0;$log1<$a;$log1++){
        $logic[$log]= $logic[$log]+getPerbandingan($pelamarid[$log1][0],$pelamarid[$log][0]);
    }
    echo "<td>$logic[$log]</td>";
}
echo "</tr>";
//echo "<tr><td>$logic[0]</td><td>$logic[1]</td><td>$logic[2]</td><td>$logic[3]</td><td>$logic[4]</td></tr>";
echo "</table>";

echo "<br/><br/><br/><table border=1>";
$baris[]="";
$vp[]="";
for($l=0;$l<$a;$l++){
    echo "<tr>";
    for($k=0;$k<$a;$k++){
        echo "<td>".round(getPerbandingan($pelamarid[$log][0],$pelamarid[$log1][0])/$logic[$l],2)."</td>";
        $baris[$l]=$baris[$l]+round(getPerbandingan($pelamarid[$log][0],$pelamarid[$log1][0])/$logic[$l],2);
    }
    $vp[$l]=$baris[$l]/5;
    echo "<td>$baris[$l]</td><td>".($baris[$l]/5)."</td></tr>";
}
echo "</table>";

echo "<br/><br/><br/><table border=1>";
$baris2[]="";
for($log=0;$log<$a;$log++){
    echo "<tr>";
    for($log1=0;$log1<$a;$log1++){
        echo "<td>".(getPerbandingan($pelamarid[$log][0],$pelamarid[$log1][0])*($baris[$log1]/5))."</td>";
        $baris2[$log]=$baris2[$log]+(getPerbandingan($pelamarid[$log][0],$pelamarid[$log1][0])*($baris[$log1]/5));
    }
    echo "<td>$baris2[$log]</td></tr>";
}
echo "</table>";
$lamda = 0;
echo "<br/><br/><br/><table border=1>";
for($log=0;$log<$a;$log++){
    echo "<tr><td>".round($baris2[$log]/$vp[$log])."</td></tr>";
    $lamda = $lamda+round($baris2[$log]/$vp[$log]);
}
echo "</table>";

$lamdamax = $lamda/5;

echo "Lamda Maks : $lamdamax<br/><br/>";
$ci = ($lamdamax-5)/(5-1);
echo "CI : $ci<br/><br/>";

if($ci<0.1){
    echo "true<br/><br/>";
}
else{
    echo "false<br/><br/>";
}

?>
